//
//  CashPayDetailViewController.m
//  sys_eric
//
//  Created by mac on 11-11-21.
//  Copyright 2011年 __MyCompanyName__. All rights reserved.
//

#import "CashPayDetailViewController.h"


@implementation CashPayDetailViewController

@synthesize startTime;
@synthesize endTime;
@synthesize payTime;
@synthesize amountOfChash;
@synthesize numberOfMessage;
@synthesize remark;


-(void)backgroundTap
{
    [startTime resignFirstResponder];
    [endTime resignFirstResponder];
    [payTime resignFirstResponder];
    [amountOfChash resignFirstResponder];
    [numberOfMessage resignFirstResponder];
    [remark resignFirstResponder];
}

- (void)viewDidLoad
{
    self.title=@"现金支付明细";
    UITableView *tab=[[UITableView alloc]initWithFrame:CGRectMake(0, 0, 320, 480) style:UITableViewStyleGrouped];
    self.tableView=tab;
    UIControl *background=[[UIControl alloc]initWithFrame:CGRectMake(0, 0, 320, 480)];
    [background addTarget:self action:@selector(backgroundTap) forControlEvents:UIControlEventTouchUpInside];
    self.tableView.backgroundView=background; 
    UIEdgeInsets edgeinsets=UIEdgeInsetsMake(0, 0, 0, 0);//为什么只有前两个参数起作用？？？
    self.tableView.contentInset=edgeinsets;
    self.tableView.delegate=self;
    self.tableView.dataSource=self;
    self.tableView.scrollEnabled=YES;
    [tab release];
    [super viewDidLoad];
}

-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
    [textField resignFirstResponder];
    return YES;
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    
    // Return the number of sections.
    return 3;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    
    if (section==0) {
        return 3;
    }
    return 4;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSUInteger section = [indexPath section];
    NSUInteger row = [indexPath row];
    
    static NSString *CellIdentifier = @"Cell";
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    }
    
    if (section==0) 
    {
        switch (row) 
        {
            case 0:
            {cell.textLabel.text = @"日期:";
                break;}
                
            case 1:
            {
                UITextField *start=[[UITextField alloc] initWithFrame:CGRectMake(50,4,220, 35)];
                self.startTime=start;
                start.borderStyle = UITextBorderStyleNone;//UITextBorderStyleRoundedRect;
                start.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
                [cell.contentView addSubview:start];
                start.delegate = self;
                start.secureTextEntry=YES;
                start.keyboardType=UIKeyboardTypeNumberPad;
                start.borderStyle=UITextBorderStyleRoundedRect;
                [start release];
                break;}
            case 2:
            {
                UITextField *end=[[UITextField alloc] initWithFrame:CGRectMake(50,4,220, 35)];
                self.endTime=end;
                end.borderStyle = UITextBorderStyleNone;//UITextBorderStyleRoundedRect;
                end.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
                [cell.contentView addSubview:end];
                end.delegate = self;
                end.secureTextEntry=YES;
                end.keyboardType=UIKeyboardTypeNumberPad;
                end.borderStyle=UITextBorderStyleRoundedRect;
                [end release];
                break;}
            default: 
                break;
        }
        
    }
    
    else
    {
        switch (row) {
            case 0:
            {cell.textLabel.text = @"支付时间:";
                UITextField *pay=[[UITextField alloc] initWithFrame:CGRectMake(100,4,170, 35)];
                self.payTime=pay;
                pay.borderStyle = UITextBorderStyleNone;//UITextBorderStyleRoundedRect;
                pay.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
                [cell.contentView addSubview:pay];
                pay.delegate = self;
                pay.secureTextEntry=YES;
                pay.keyboardType=UIKeyboardTypeNumberPad;
                [pay release];
                break;}
            case 1:
            {cell.textLabel.text = @"支付现金额:";
                UITextField *amout=[[UITextField alloc] initWithFrame:CGRectMake(120,4,150, 35)];
                self.amountOfChash=amout;
                amout.borderStyle = UITextBorderStyleNone;//UITextBorderStyleRoundedRect;
                amout.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
                [cell.contentView addSubview:amout];
                amout.delegate = self;
                amout.secureTextEntry=YES;
                amout.keyboardType=UIKeyboardTypeNumberPad;
                [amout release];
                break;}
            case 2:
            {cell.textLabel.text = @"充入短信数量:";
                UITextField *number=[[UITextField alloc] initWithFrame:CGRectMake(140,4,130, 35)];
                self.numberOfMessage=number;
                number.borderStyle = UITextBorderStyleNone;//UITextBorderStyleRoundedRect;
                number.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
                [cell.contentView addSubview:number];
                number.delegate = self;
                number.secureTextEntry=YES;
                number.keyboardType=UIKeyboardTypeNumberPad;
                [number release];
                break;}
            case 3:
            {cell.textLabel.text = @"备注:";
                UITextField *mark=[[UITextField alloc] initWithFrame:CGRectMake(60,4,210, 35)];
                self.remark=mark;
                mark.borderStyle = UITextBorderStyleNone;//UITextBorderStyleRoundedRect;
                mark.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
                [cell.contentView addSubview:mark];
                mark.delegate = self;
                mark.secureTextEntry=YES;
                mark.keyboardType=UIKeyboardTypeNumberPad;
                [mark release];
                break;}        
            default: 
                break;
        }
    }
	cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
    return cell;
    
}
-(void)commitChangePswd
{
    NSLog(@"commitChangePswd");
}

-(void)cancelChangePswd
{
    NSLog(@"cancelChangePswd");
}


- (id)initWithStyle:(UITableViewStyle)style
{
    self = [super initWithStyle:style];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)dealloc
{
    [startTime release];
    [endTime release];
    [payTime release];
    [amountOfChash release];
    [numberOfMessage release];
    [remark release];
    [super dealloc];
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

- (void)viewDidUnload
{
    self.startTime=nil;
    self.endTime=nil;
    self.payTime=nil;
    self.amountOfChash=nil;
    self.numberOfMessage=nil;
    self.remark=nil;
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
}

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
}

- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
}

- (void)viewDidDisappear:(BOOL)animated
{
    [super viewDidDisappear:animated];
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}


/*
// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
    // Return NO if you do not want the specified item to be editable.
    return YES;
}
*/

/*
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        // Delete the row from the data source
        [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
    }   
    else if (editingStyle == UITableViewCellEditingStyleInsert) {
        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
    }   
}
*/

/*
// Override to support rearranging the table view.
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath
{
}
*/

/*
// Override to support conditional rearranging of the table view.
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
{
    // Return NO if you do not want the item to be re-orderable.
    return YES;
}
*/

#pragma mark - Table view delegate

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    // Navigation logic may go here. Create and push another view controller.
    /*
     <#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:@"<#Nib name#>" bundle:nil];
     // ...
     // Pass the selected object to the new view controller.
     [self.navigationController pushViewController:detailViewController animated:YES];
     [detailViewController release];
     */
}

@end
